package com.example.withroadlogistics.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.withroadlogistics.R;
import com.example.withroadlogistics.model.TRule;

import java.util.List;

public class Adapter_RuleNo extends BaseAdapter {
    private Context context;
    private List<TRule> list;

    //private Province data;
    //布局加载器
    private LayoutInflater inflater;

    public Adapter_RuleNo(Context context, List<TRule> list) {
        this.context = context;
        this.list = list;
        //获取系统服务
        inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        view=inflater.inflate(R.layout.rule_item,null);

        TextView tv1=view.findViewById(R.id.taskID);
        TextView tv2=view.findViewById(R.id.carId);
        TextView tv3=view.findViewById(R.id.registerTime);
        TextView tv4=view.findViewById(R.id.ruTime);
        TextView tv5=view.findViewById(R.id.ruContent);
        TextView tv6=view.findViewById(R.id.ruRemark);
        tv1.setText(list.get(i).getTaskId());
        tv2.setText(list.get(i).getCarId());
        tv3.setText(list.get(i).getRegisterTime());
        tv4.setText(list.get(i).getRuTime());
        tv5.setText(list.get(i).getRuContent());
        tv6.setText(list.get(i).getRuRemark());
        return view;
    }
}
